package com.fm.demo.activity

import android.content.Intent
import android.os.Bundle
import androidx.core.content.ContextCompat
import com.blankj.utilcode.util.ToastUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fm.common.base.BaseBActivity
import com.fm.common.utils.setLinearLayoutManager
import com.fm.demo.R
import com.fm.demo.databinding.ActivityLoadingBinding
import com.fm.demo.widget.NoScrollLinearLayoutManager

class LoadingActivity : BaseBActivity<ActivityLoadingBinding>() {

    override fun initView(savedInstanceState: Bundle?) {

        initToolbar(binding.rootToolbar, "Test", true)
        val adapter = TestAdapter()
        val data = ArrayList<String>()
        data.add("1")
        data.add("2")
        adapter.setList(data)
        val layoutManager = NoScrollLinearLayoutManager(mContext)
        layoutManager.setScrollEnable(false)
        binding.loadRlvTest.setLinearLayoutManager(mContext, 10)
        binding.loadRlvTest.adapter = adapter
        binding.loadRlvTest.isEnabled = false
        adapter.setOnItemClickListener { _, _, position ->
            ToastUtils.showShort(position)
        }
    }


    class TestAdapter : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_joke_image_layout) {

        override fun convert(holder: BaseViewHolder, item: String) {
            holder.setImageDrawable(R.id.item_joke_image_iv, ContextCompat.getDrawable(context, R.drawable.test))
        }

    }
}